home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.3)
-
- import common
- import zlib
- from wxPython.wx import *
-
- class Display(wxFrame):
-
- def __init__(self, file, parent = None):
- bmp = getbitmap(file)
- wxFrame.__init__(self, parent, -1, 'Image Display')
- b = wxStaticBitmap(self, -1, bmp)
- b.SetSize((bmp.GetWidth(), bmp.GetHeight()))
- self.Fit()
- self.Show(True)
-
-
-
- class MyImage:
-
- def __init__(self, width, height, bytes, palette):
- self.width = width
- self.height = height
- offset = 0
- import cStringIO
- data = cStringIO.StringIO()
- for row in range(height):
- while offset % 4 != 0:
- offset += 1
- for col in range(width):
- v = ord(bytes[offset])
- offset += 1
- data.write(palette[v])
-
-
- self.data = data.getvalue()
-
-
- def toImage(self):
- img = wxEmptyImage(self.width, self.height)
- img.SetData(self.data)
- return img
-
-
-
- class BCIPalette:
-
- def __init__(self, data = ''):
- pal = []
- for offset in range(0, len(data), 4):
- pal.append(data[offset + 2] + data[offset + 1] + data[offset])
-
- self.pal = pal
-
-
- def __getitem__(self, e):
- return self.pal[e]
-
-
-
- def getimage(file):
- f = open(file, 'rb')
- data = f.read()
- f.close()
- palettes = { }
- imageoffset = readlsb(data[8:11])
- width = readlsb(data[14:16])
- height = readlsb(data[16:18])
- numitem1 = readlsb(data[18:20])
- numitem2 = readlsb(data[20:22])
- numitem3 = readlsb(data[22:24])
- numpalettes = numitem1
- numotherthing = numitem2
- numimages = numitem3
- bpp = readlsb(data[26:28])
- offset = 28
- for _ in range(numpalettes):
- id = readlsb(data[offset:offset + 2])
- offset += 2
- numentries = readlsb(data[offset:offset + 2])
- offset += 2
- pal = BCIPalette(data[offset:offset + numentries * 4])
- offset += numentries * 4
- palettes[id] = pal
-
- for _ in range(numotherthing):
- offset += 20
-
- for _ in range(numimages):
- szdata = readlsb(data[offset:offset + 4])
- width = readlsb(data[offset + 4:offset + 6])
- height = readlsb(data[offset + 6:offset + 8])
- id1 = readlsb(data[offset + 8:offset + 10])
- id2 = readlsb(data[offset + 10:offset + 12])
- offset += 12
- buf = data[offset:offset + szdata]
- res = zlib.decompress(buf)
- img = MyImage(width, height, res, palettes[id2])
- return img.toImage()
-
-
-
- def readlsb(data):
- res = 0
- shift = 0
- for i in data:
- res |= ord(i) << shift
- shift += 8
-
- return res
-
- if __name__ == '__main__':
- wxInitAllImageHandlers()
- app = wxPySimpleApp()
- if len(sys.argv) == 2:
- f = Display(sys.argv[1])
- elif len(sys.argv) == 3:
- bciconvert(sys.argv[1], sys.argv[2])
- f = Display(sys.argv[2])
-
- app.MainLoop()
-
-